package main;

import java.util.Vector;

import engine.AlternateStateThreadPoolExecutor;
import utils.Debug;
import utils.SimulatedUser;
import visualisation.MainFrame;
import XML.FragmentXML;
import XML.XMLParser;
import entities.FragmentDirectory;
import entities.MMMEDirectory;
import fragment.Fragment;

public class Main {
	
	
	public final static boolean lowPerf = false;
	
	public final static String finalElement ="Application";	//final element, determine that a process is complete

	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		/**/
		//Debug.debug();
		
		new AlternateStateThreadPoolExecutor();
		AlternateStateThreadPoolExecutor.processExe.pause();
		
		Vector<FragmentXML> vectorFragments =XMLParser.parser("src/INGENIAS.xml");

//		Vector<FragmentXML> vectorFragments =XMLParser.parser("src/ADELFE.xml");
//		vectorFragments.addAll(XMLParser.parser("src/INGENIAS.xml"));
		
		//Vector<FragmentXML> vectorFragments =XMLParser.parser("src/ProcessTest.xml");
		//Vector<FragmentXML> vectorFragments =XMLParser.parser("src/ProcessTestCompatible.xml");
		//Vector<FragmentXML> vectorFragments =XMLParser.parser("src/ADELFEexp.xml");		
		
		
		FragmentDirectory fragDir = new FragmentDirectory();
		MMMEDirectory elemDir =  new MMMEDirectory();
						
		Vector<Fragment> fragList=new Vector<Fragment>();
		
		for(FragmentXML f : vectorFragments)
			fragList.add(FragmentFactory.create(f.getName(),f.getOutput(),f.getInput(),f.getPreference(),fragDir,elemDir));
		
		
		new MainFrame(fragList);
		
		(new Thread(new ProcessFinder(fragDir, elemDir))).start();
		
		for(Fragment f : fragList)
			f.start();
		
		//new SimulatedUser(elemDir).start();

	}
	


}
